﻿@model Entidades.Seguridad.Formulario

@{
    ViewBag.Title = "Editar";
    Layout = "~/Views/Shared/_Layout.cshtml";
    List<Entidades.Seguridad.Permiso> listPermisos = ViewBag.Permisos;
}

<h2>Edit</h2>
<link href="../../Content/themes/bootstrap.extra.table.css" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Formulario</legend>
        
        @Html.HiddenFor(model => model.IdFormulario)
        <div class="clearfix">
            @Html.LabelFor(model => model.IdFormulario)
        
            <div class="input">
                @Html.TextBoxFor(model => model.IdFormulario,new { disabled = "disabled" })
                @Html.ValidationMessageFor(model => model.IdFormulario)
            </div>
        </div>


        <div class="clearfix">
            @Html.LabelFor(model => model.Nombre)
        
            <div class="input">
                @Html.EditorFor(model => model.Nombre)
                @Html.ValidationMessageFor(model => model.Nombre)
            </div>
        </div>

        <div class="clearfix">
            @Html.LabelFor(model => model.Descripcion)
        
            <div class="input">
                @Html.EditorFor(model => model.Descripcion)
                @Html.ValidationMessageFor(model => model.Descripcion)
            </div>
        </div>
        
        <div class="clearfix">
            <label for="permisoschecks">Permisos</label>
            <div class="input">
                    @foreach (var c in listPermisos)
                    {
                         if (Model.Permisos.Any(x => x.IdPermiso == c.IdPermiso))
                         {
                             <p>
                                 <input type="checkbox" name="permisoschecks" value="@c.IdPermiso" checked="checked"> @c.Nombre
                             </p>
                         }
                        else
                        {
                             <p>
                                 <input type="checkbox" name="permisoschecks" value="@c.IdPermiso"> @c.Nombre
                             </p>
                        }
                         
                    }
            </div>
        </div>


        <div class="actions">
            <input type="submit" class="btn primary" value="Guardar" />
            @Html.ActionLink("Cancelar", "Index", null, new { @class = "btn" })
        </div>
    </fieldset>
}
